﻿using System;
using System.IO;
using System.Data;
using System.Security.AccessControl;

using VisualStudioSensor;
using TeamFoundationServerSensor;

/// <summary>
/// Summary description for FormValidator
/// </summary>
public static class FormValidator {

    /// <summary>
    /// Determines whether a file is accessible.
    /// </summary>
    /// <param name="path">The path to the file.</param>
    /// <returns>True if file can be accessed correctly.</returns>
    public static Boolean FileAccessible(string path) {
    
        // Check if the file exists.
        if (!File.Exists(path)) {
            Logger.TheInstance.Log("File could not be found: " + path, LogLevel.Error);
        }

        // File is accessible.
        else {
            return true;
        }

        // File is not accessible.
        return false;
    }

    /// <summary>
    /// Used to determine whether the BisSubscribe tool can be used.
    /// </summary>
    /// <param name="BisSubscribe">The path to the BisSubscribe tool.</param>
    /// <returns>True if tool exists. False otherwise.</returns>
    public static Boolean CheckBisSubscribeTool(string BisSubscribe) {

        // Check to make sure the value for the BisSubscribe tool are correct.
        if (BisSubscribe == null || BisSubscribe.Equals(string.Empty)) {
            throw new ArgumentException("Value for BisSubscribe cannot be null or empty.");
        }
        else if (!File.Exists(BisSubscribe)) {
            throw new ArgumentException("BisSubscribe could not be found at the specificed path.");
        }

        return true;
    }
}
